#ifndef JWAITBOX_H
#define JWAITBOX_H

#include <functional>
#include <QTEGui/qteguiglobal.h>
#include <QWidget>

namespace QTE
{

class JWaitBar;
class JWaitBoxPrivate;

// 无尽的等待框
class QTEGUI_EXPORT JWaitBox : public QWidget
{
	Q_OBJECT

public:
	explicit JWaitBox(QWidget *parent = nullptr);
	explicit JWaitBox(const QString &msg, QWidget *parent = nullptr);
	~JWaitBox() override;

public:
    void exec(bool fill = false);

public Q_SLOTS:
	void setMessage(const QString &msg);
	void setCancelButtonVisible(bool visible = true);
	void setCancelButtonText(const QString &text);

public:
    void setWaitBar(JWaitBar *bar);
    const JWaitBar *waitBar() const;
    JWaitBar *waitBar();

public Q_SLOTS:
    void showWaitBar(int msecs = 200);
    void hideWaitBar();

Q_SIGNALS:
	void cancel();

public:
	static JWaitBox &globalInstance(const QString &msg = QString());

protected:
	void closeEvent(QCloseEvent *event) override;
    void changeEvent(QEvent *event) override;

private:
	JWaitBoxPrivate *d_ptr;
	Q_DISABLE_COPY(JWaitBox)
};

} //namespace JXQ


#endif //JWAITBOX_H
